<template>
  <div id="tab_ctrol-component">
    <div
      id="Item-component"
      v-for="(item, index) in title"
      :key="index"
      @click="change(index, item.type)"
    >
      <span :class="index == current_index ? 'color' : ''">{{
        item.title
      }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "Tab_ctrol",
  data() {
    return {
      //当中的index
      current_index: 0,
    }
  },
  props: ["title"],
  mounted() {
    this.$emit("send_type", this.title[0].type)

    // console.log(this.title[0].type)
  },
  methods: {
    change(val, type) {
      this.current_index = val

      this.$emit("send_type", type)
    },
  },
}
</script>

<style lang="less" scoped>
#tab_ctrol-component {
  display: flex;
  text-align: center;
  background-color: #fff;
}
#Item-component {
  flex: 1;
  height: 35px;
  box-sizing: border-box;
  line-height: 35px;
  span {
    font-size: 13px;
    padding: 5px;
  }
}

.color {
  color: #ff8198;
  border-bottom: 2px solid #ff8198;
}
</style>
